<?php
error_reporting(0);

$host = "127.0.0.1";
$username = "jieyou_tiansun_x";
$password = "Cs3J5knpEiFCL8LR";
$db_name = "jieyou_tiansun_x";
$conn = mysqli_connect($host,$username,$password, $db_name);

if(!$conn){
    // echo('{"code":1,"msg":"数据库连接成功"}');
    exit('{"code":-1,"msg":"数据库连接失败"}');
}

$act=$_GET['act'];  // http://localhost/api.php?act=get_order
$mark = 'mk';  // 这是自己设置的标识字段 区分对接

switch($act){
    case 'get_order':
        
        $sql = "select * from qingka_wangke_order where state = '待处理' and noun = '{$mark}'"; # 表名 自己设置 这里是 css
        $d1 = mysqli_query($conn, $sql);
        while($row = mysqli_fetch_assoc($d1)){
            $arr[] = $row;
            }
        $data = json_encode($arr, JSON_UNESCAPED_UNICODE);
        echo($data);
        break;

    case 'update_order':

        $d = $_GET['data']; #自己设置
        $data = json_decode($d,true);

        # 根据你设置的数据库字段匹配 写入
        # 数据库字段自己设置
        # 平台 账号 密码 课程名 状态 进度 详细 这几个字段必须有
        // $mark = $data['mark'];
        $platform = $data['platform'];
        $account = $data['account'];
        $password = $data['password'];
        $course = $data['course'];
        $state = $data['state'];
        $progress = $data['progress'];
        $detailed = $data['detailed'];

        $sql2 = "update qingka_wangke_order set state='{$state}',progress='{$progress}',detailed='{$detailed}' where noun='{$mark}' and account='{$account}' and password='{$password}' and course='{$course}'";
        mysqli_query($conn, $sql2);
        break;
    }



// mysqli_close($conn);
?>